/**
 * @author liuyong
 * @since 2021-05-11 10:47:56
 */
layui.define(['form', 'layedit', 'laydate', 'upload'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var upload = layui.upload;
    var loadIndex = 0;
    upload.render({
        elem: "#importData",   //导入id
        url: '/base/phenomenon/uploadExcel',
        auto: false,    // 与bindAction一起使用，不直接上传，当点击#sendMessage按钮时才上传
        bindAction: '#submitExcel',
        accept: "file",
        size: 10*1024,
        /* 允许上传文件的后缀 */
        exts: 'xls|xlsx',
        before: function () {
            loadIndex = layer.load(1, {
                shade: [0.5, '#DBDBDB']
            });
            $("#divMsg").html('');
        },
        done: function (json) {
            layer.close(loadIndex);

            /* 上传完毕回调 */
            $("#divMsg").html('');
            if (json.status == 200) {
                layer.msg(json.data);
                setTimeout(function () {
                    location.reload();
                }, 1000)
            } else if (json.status == 555) {
                var data = JSON.parse(json.message);
                if (data != null) {
                    if (data.methodMsg != null && data.methodMsg != '') {
                        $("#divMsg").append('导入检测方法文件解析失败!</br>');
                        $("#divMsg").append(data.methodMsg + '</br>');
                    }

                }
            } else {
                $("#divMsg").html(json.message);
            }
        },
        error: function (a, b, c, d) {
            layer.close(loadIndex);
            //请求异常回调
            //alert("服务器出小差啦，请稍后再试");
        }
    });


    form.render(null, "zmn-form");
    //对外暴露的接口
    exports('zmn_plat_phenomenon_excel_edit', {});
});